<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>metisMenu - Ajax</title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <link rel="stylesheet" href="metisMenu.css" />
    <link rel="stylesheet" href="demo.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/themes/prism.min.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" />
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->


    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="metisMenu.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.6.0/prism.min.js"></script>

    <script async defer src="https://buttons.github.io/buttons.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-noty/2.4.1/packaged/jquery.noty.packaged.min.js"></script>
  </head>

  <body>

    <nav class="navbar navbar-default navbar-static-top" role="navigation">
      <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.html">metisMenu</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                Examples <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="mm-vertical.html">Vertical Menu</a></li>
                <li><a href="mm-horizontal.html">Horizontal Menu</a></li>
                <li><a href="mm-folder.html">Folder View</a></li>
                <li><a href="mm-vertical-hover.html">Hover Option For Desktop</a></li>
                <li><a href="mm-zurb.html">Foundation | Zurb</a></li>
                <li><a href="mm-animate.html">Animate</a></li>
                <li><a href="mm-event.html">Event</a></li>
                <li><a href="mm-event2.html">Event 2</a></li>
                <li><a href="mm-dispose.html">Stop & Start metisMenu</a></li>
                <li><a href="mm-ajax.html">Ajax</a></li>
                <li><a href="mm-faq.html">FAQ</a></li>
              </ul>
            </li>

            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                Admin Templates <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="http://chl.onokumus.com" target="_blank">Chaldene Admin</a></li>
                <li><a href="http://elk.onokumus.com" target="_blank">Elektron Admin</a></li>
                <li><a href="http://onokumus.github.io/twbuttons/" target="_blank">twbuttons</a></li>
              </ul>
            </li>

            <li><a href="http://onokumus.com" target="_blank">onokumus</a></li>

          </ul>
        </div>
        <!-- /.navbar-collapse -->
      </div>
      <!-- /.container-fluid -->
    </nav>

<link href="css/mm-vertical.css" rel="stylesheet" type="text/css" />

<div class="container">
  <div class="row">
    <div class="col-md-3">
      <nav class="sidebar-nav">
        <ul class="metismenu" id="menu">
          <li>
            <a class="has-arrow" href="#">
              <span class="fa fa-fw fa-github fa-lg"></span>
              metisMenu
            </a>
            <ul aria-expanded="true">
              <li>
                <a href="https://github.com/onokumus/metisMenu">
                  <span class="fa fa-fw fa-code-fork"></span> Fork
                </a>
              </li>
              <li>
                <a href="https://github.com/onokumus/metisMenu">
                  <span class="fa fa-fw fa-star"></span> Star
                </a>
              </li>
              <li>
                <a href="https://github.com/onokumus/metisMenu/issues">
                  <span class="fa fa-fw fa-exclamation-triangle"></span> Issues
                </a>
              </li>
            </ul>
          </li>
          <li>
            <a class="has-arrow" href="#" aria-expanded="false">Menu 0</a>
            <ul aria-expanded="false">
              <li><a href="#">item 0.1</a></li>
              <li><a href="#">item 0.2</a></li>
              <li><a href="http://onokumus.com">onokumus</a></li>
              <li><a href="#">item 0.4</a></li>
            </ul>
          </li>
          <li id="removable">
            <a class="has-arrow" href="#" aria-expanded="false">Menu 1</a>
            <ul aria-expanded="false">
              <li><a href="#">item 1.1</a></li>
              <li><a href="#">item 1.2</a></li>
              <li>
                <a class="has-arrow" href="#" aria-expanded="false">Menu 1.3</a>
                <ul aria-expanded="false">
                  <li><a href="#">item 1.3.1</a></li>
                  <li><a href="#">item 1.3.2</a></li>
                  <li><a href="#">item 1.3.3</a></li>
                  <li><a href="#">item 1.3.4</a></li>
                </ul>
              </li>
              <li><a href="#">item 1.4</a></li>
              <li>
                <a class="has-arrow" href="#" aria-expanded="false">Menu 1.5</a>
                <ul aria-expanded="false">
                  <li><a href="#">item 1.5.1</a></li>
                  <li><a href="#">item 1.5.2</a></li>
                  <li><a href="#">item 1.5.3</a></li>
                  <li><a href="#">item 1.5.4</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li>
            <a class="has-arrow" href="#" aria-expanded="false">Menu 2</a>
            <ul aria-expanded="false">
              <li><a href="#">item 2.1</a></li>
              <li><a href="#">item 2.2</a></li>
              <li><a href="#">item 2.3</a></li>
              <li><a href="#">item 2.4</a></li>
            </ul>
          </li>
        </ul>
      </nav>
    </div>
    <div class="col-md-9">
      <h3>Simple Ajax</h3>
      <div class="panel panel-default">
        <div class="panel-heading">
          Code
          <span class="pull-right">
                <span class="fa fa-code"></span>
          </span>
        </div>
        <div class="panel-body">
          <button type="button" class="btn btn-info btn-lg" id="ajaxButton">
            get ajax menu
          </button>

          <p>

<pre><code class="language-javascript">$('#menu').metisMenu();

$(&quot;#ajaxButton&quot;).one('click', function() {
  var $this = $(this);
  $.ajax({
    url: &quot;demo-ajax.html&quot;,
    success: function(result) {

      $('#menu').metisMenu('dispose');
      $(&quot;#menu&quot;).append(result);

      $('#menu').metisMenu();
      $this.attr('disabled', 'disabled');
    }
  });
});
</code></pre>

          </p>
        </div>
      </div>
    </div>
  </div>
</div>


<div class="container">
  <div class="row">
    <div class="col-md-3">
      <nav class="sidebar-nav">

        <ul class="metismenu" id="menu2">
          <li><a href="" class="has-arrow" data-url="ajax-1.html">Ajax Menu 1</a></li>
          <li><a href="" class="has-arrow" data-url="ajax-2.html">Ajax Menu 2</a></li>
          <li><a href="" class="has-arrow" data-url="ajax-3.html">Ajax Menu 3</a></li>
          <li><a href="" class="has-arrow" data-url="ajax-4.html">Ajax Menu 4</a></li>
        </ul>

      </nav>
    </div>
    <div class="col-md-9">
      <h3>Simple Ajax <small>one level</small></h3>
      <div class="panel panel-default">
        <div class="panel-heading">
          Code
          <span class="pull-right">
                <span class="fa fa-code"></span>
          </span>
        </div>
        <div class="panel-body">

          <p>

<pre><code class="language-javascript">  $('#menu2').metisMenu();

  $(&quot;[data-url]&quot;).each(function(){
      $(this).one('click', function(event){
        event.preventDefault();
        var $this = $(this);
        var url = $this.attr('data-url');
        console.log(url);

        $.ajax({
          url: url,
          success: function(result) {

            $('#menu2').metisMenu('dispose');
            $this.parent('li').append(result);

            $('#menu2').metisMenu();

            $this.click();
          }
        });

      });
  });
</code></pre>

          </p>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  $(function() {

    $('#menu').metisMenu();

    $("#ajaxButton").one('click', function() {
      var $this = $(this);
      $.ajax({
        url: "demo-ajax.html",
        success: function(result) {

          $('#menu').metisMenu('dispose');
          $("#menu").append(result);

          noty({
              text: 'ajax menu appended to menu',
              layout: 'topRight',
              type: 'success',
              theme: 'metroui',
              progressBar: true,
              timeout: 2000
          });

          $('#menu').metisMenu();
          $this.attr('disabled', 'disabled');
        }
      });
    });

    $('#menu2').metisMenu();

    $("[data-url]").each(function(){
        $(this).one('click', function(event){
          event.preventDefault();
          var $this = $(this);
          var url = $this.attr('data-url');
          console.log(url);

          $.ajax({
            url: url,
            success: function(result) {

              $('#menu2').metisMenu('dispose');
              $this.parent('li').append(result);

              $('#menu2').metisMenu();

              $this.click();
            }
          });

        });
    });

  });
</script>





  </body>

</html>
